package com.codemes.happylist.lucene.reader;

import java.util.Arrays;

/**
 * @author <a href="mail:fulei@fehorizon.com">fulei</a>
 * @date 2022/8/22 18:55
 */
public enum FileTypeEnum {

    // ["zip","jpg","psd","pptx","xlsx","pdf","png","doc","html","docx"]
    ZIP("zip"),
    JPG("jpg"),
    PSD("psd"),
    PPTX("pptx"),
    XLSX("xlsx"),
    PDF("pdf"),
    PNG("png"),
    DOC("doc"),
    HTML("html"),
    DOCX("docx"),
    ;

    private final String code;

    FileTypeEnum(String code){
        this.code = code;
    }

    public static FileTypeEnum getByCode(String fileType) {
        FileTypeEnum[] fileTypeEnums = FileTypeEnum.values();
        return Arrays.stream(fileTypeEnums).filter(type -> type.getCode().equals(fileType)).findFirst().orElse(null);
    }

    public String getCode() {
        return code;
    }
}
